package com.usian.admin.controller;

import com.usian.admin.service.WemediaNewsAutoScanService;
import com.usian.apis.admin.NewsAuthControllerApi;
import com.usian.model.admin.dtos.NewsAuthDto;
import com.usian.model.common.dtos.PageResponseResult;
import com.usian.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/news_auth")
public class NewsAuthController implements NewsAuthControllerApi {

    @Autowired
    private WemediaNewsAutoScanService wemediaNewsAutoScanService;

    /**
     * 查询人工审核列表
     * @param dto
     * @return
     */
    @Override
    @PostMapping("/list")
    public PageResponseResult findNews(@RequestBody NewsAuthDto dto) {
        return wemediaNewsAutoScanService.findNews(dto);
    }

    /**
     * 人工审核查看详情
     * @param id
     * @return
     */
    @Override
    @GetMapping("/one/{id}")
    public ResponseResult findById(@PathVariable Integer id) {
        return wemediaNewsAutoScanService.findById(id);
    }

    /**
     * 审核通过 4
     * @param dto
     * @return
     */
    @PostMapping("/auth_pass")
    @Override
    public ResponseResult authPass(@RequestBody NewsAuthDto dto) {
        return wemediaNewsAutoScanService.updateStatus(1,dto);
    }

    /**
     * 审核不通过 2
     * @param dto
     * @return
     */

    @Override
    @PostMapping("/auth_fail")
    public ResponseResult authFail(@RequestBody NewsAuthDto dto) {
        return wemediaNewsAutoScanService.updateStatus(0,dto);
    }
}
